/*
 * Created by SharpDevelop.
 * User: K 3 N ! L
 * Date: 12/21/2008
 * Time: 1:24 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Data;
using System.Windows.Forms;

namespace ChallanSystem
{
	/// <summary>
	/// Description of Util.
	/// </summary>
	public class Util
	{
		public Util()
		{
		}
		
		public DataTable Search(DataTable dt, string filter, string columnName)
		{
			DataTable dtFiltered = dt.Clone();
			//MessageBox.Show("Filter Criteria : "+filter);
			try
			{
				//MessageBox.Show("DataTable count : "+dt.DefaultView.Count);
				
				filter = columnName+" like '"+filter+"%'";
				
				foreach(DataRow dr in dt.Select(filter))
				{
					//MessageBox.Show("in for ");
					dtFiltered.ImportRow(dr);
				}
			}
			catch(Exception e)
			{
				MessageBox.Show("Exception : "+e.ToString());
			}
			return dtFiltered;
		}
				
	}
}
